<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>用户管理</el-breadcrumb-item>
      <el-breadcrumb-item>用户列表</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card>
      <el-row :gutter="20">
        <el-col :span="8">
          <el-input placeholder="请输入内容">
            <el-button slot="append" icon="el-icon-search"></el-button>
          </el-input>
        </el-col>
        <el-col :span="4">
          <el-button type="primary">添加用户</el-button>
        </el-col>
      </el-row>
	  <el-table :data="userlist" border :stripe="true">
		  <el-table-column type="index" label="索引"></el-table-column>
		  <el-table-column prop="username" label="姓名"></el-table-column>
		  <el-table-column prop="email" label="邮箱"></el-table-column>
		  <el-table-column prop="phone" label="电话"></el-table-column>
		  <el-table-column prop="role" label="角色"></el-table-column>
		  <el-table-column prop="status" label="状态">
			 
			  <!-- <通过具名插槽来显示一个插件没有弄明白 ---vue slot？？？> -->
			  
				  <template v-slot="status">
					  <el-switch v-model="status.is"></el-switch>
				  </template>
			  
		  </el-table-column>
		  <el-table-column prop="ops" label="操作"></el-table-column>
	  </el-table>
    </el-card>
  </div>
</template>

<script>
export default {
	data(){
		return{
			queryInfo:{
				query:'',
				pagenum:1,
				pagesize:2
			},
			userlist:[],
			total:0,
			
		}
	},
	methods:{
		async getUserList(){
			const{data:res} = await this.$http.get('users', {
				params:this.queryInfo
			})
			if(res.meta.status!==200){
				return this.$message.error("数据列表获取失败")
			}
			this.userlist = res.data.users
			this.total = res.data.total
		},
		fakerGetUserList(){
			this.userlist = [
				{
					username:'admin',
					email:'111@111',
					phone:'11111',
					role:'超级管理员',
					status:{is:true}
					
				},
				{
					username:'gcc',
					email:'222@222',
					phone:'22222',
					role:'test',
					stutas:false,
				}
			]
		}		
	},
	created() {
		this.getUserList()
		this.fakerGetUserList()
	}
}
</script>

<style lang="scss" scoped>
.el-breadcrumb {
  margin-bottom: 10px;
}
.el-table{
	margin-top: 15px;
}
</style>
